﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MyMaster.Master" AutoEventWireup="true"
    CodeBehind="ModelManage.aspx.cs" Inherits="FashionMural.Admin.ModelManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="LeftMenu" runat="server">
    <script type="text/javascript">
        var showflag = true;
        function showHideUl() {
            $("#modelInfo").click(
                function () {
                    if (showflag) {
                        $("#modelInfoChild").hide();
                        showflag = false;
                    } else {
                        $("#modelInfoChild").show();
                        showflag = true;
                    }
                }
            );
        }

        function showTable(id) {
            $("#leaveMessageTable").hide();
            $("#joinusMessageTable").hide();
            $("#friendLinkTable").hide();
            $("#" + id).show();
        }

        function initTable() {
            $("#leaveMessageTable").show();
            $("#joinusMessageTable").hide();
            $("#friendLinkTable").hide();
        }

        var checked = true;
        function seletedAll(tableId) {
            if (checked) {
                $("#" + tableId + " input[type=checkbox]").attr("checked", true);
                checked = false;
            } else {
                $("#" + tableId + " input[type=checkbox]").attr("checked", false);
                checked = true;
            }
        }

        function delteSelectedContent(tableId) {
            var checks = $("#" + tableId + " input[type=checkbox][checked=true]");
            deleteListContent(tableId, checks);
        }

        //0表示leavemessage,1jionusmessage,2friendlink
        function ModelAshow(flag) {
            switch (flag) {
                case 0:
                    {
                        $("#showcurrent")[0].innerHTML = "用户留言";
                        DynamicBuildSeparatePageLabel(10, "leaveseparate", "LeaveMessage");
                        showTable("leaveMessageTable");
                    } break;
                case 1:
                    {
                        $("#showcurrent")[0].innerHTML = "加盟留言";
                        //joinusseparate
                        DynamicBuildSeparatePageLabel(10, "joinusseparate", "JoinUsMessage");
                        showTable("joinusMessageTable");
                    } break;
                case 2:
                    {
                        $("#showcurrent")[0].innerHTML = "友情链接";
                        DynamicBuildSeparatePageLabel(10, "friendlinkseparate", "FriendLink");
                        showTable("friendLinkTable");
                    } break;
            }

        }

        function addFriendLink() {
            var title = $("#addfriendtitle").val();
            var furl = $("#addfriendurl").val();
            $.ajax({
                type: "POST",
                async: false,
                url: "/jsserver/friendlink/add.aspx",
                data: { title: title, furl: furl },
                success: function (data) {
                    if (data > 0) {
                        $("#friendLinkTr").after("<tr id='friendnewaddtr" + data +
                        "'><td><input type='checkbox' id='friendnewaddcheck" + data + "' value='" + data +
                        "'/></td><td><input type='text' id='friendtitle" + data + "' value='" + title +
                        "'/></td><td><input type='text' id='friendurl" + data + "' value='" + furl +
                        "'></td><td><label id='editfriendbtn" + data +
                        "' class='btn' onclick=\"updateFriendLink(" + data + ")\">更新</label><label id=\"deletefriendbtn" + data +
                        "\" class='btn' onclick='deleteContent(\"FriendLink\",\"" + data + "\");'>删除</label></td></tr>");
                        $("#jumpDivFriendLink").hide();
                    }
                },
                error: function () {
                    alert('添加失败！');
                }
            }
   );
         }

        $().ready(function () {
            showHideUl();

            //init leaveMessage table
            initTable();
            ModelAshow(0);

            //init jumpdiv
            $("#jumpDivFriendLink").hide();
        });
    </script>
    <div class="leftMenuTitle" id="modelInfo" style="cursor: pointer;">
        模块信息
    </div>
    <ul class="leftMenu" id="modelInfoChild">
        <li><a href="#" onclick="ModelAshow(0)">用户留言</a></li>
        <li><a href="#" onclick="ModelAshow(1)">加盟留言</a></li>
        <li><a href="#" onclick="ModelAshow(2)">友情链接</a></li>
        <li><a href="/QuestionNaire.aspx">问卷调查</a></li>
    </ul>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MidContent" runat="server">
    <div id="mainMenu">
        <ul>
            <li><a id="showcurrent" href="#"></a></li>
        </ul>
    </div>
    <div id="main">
        <table id="leaveMessageTable" class="mainTable">
            <tr id="leaveMessageTr" style="background-color: #D7D7D7;">
                <th>
                    选取
                </th>
                <th>
                    用户
                </th>
                <th>
                    留言时间
                </th>
                <th>
                    用户电话
                </th>
                <th>
                    操作
                </th>
            </tr>
            <tr>
                <td colspan="5" style="text-align: center;">
                    <input id="leaveSelectAll" type="checkbox" value="-1" style="margin-right: 10px;"
                        onclick="seletedAll('leaveMessageTable');" />
                    <input id="deleteSeleted" value="删除选中项" class="btn" style="height: 15px; width: 80px;
                        text-align: center;" onclick="delteSelectedContent('leaveMessageTable')" />
                </td>
            </tr>
            <tr>
                <td id="leaveseparate" colspan="5">
                </td>
            </tr>
        </table>
        <table id="joinusMessageTable" class="mainTable">
            <tr id="joinusMessageTr" style="background-color: #D7D7D7;">
                <th>
                    选取
                </th>
                <th>
                    用户
                </th>
                <th>
                    用户手机
                </th>
                <th>
                    用户电话
                </th>
                <th>
                    联系时间
                </th>
                <th>
                    操作
                </th>
            </tr>
            <tr>
                <td colspan="6" style="text-align: center;">
                    <input id="Checkbox1" type="checkbox" value="-1" style="margin-right: 10px;" onclick="seletedAll('joinusMessageTable');" />
                    <input id="Text1" value="删除选中项" class="btn" style="height: 15px; width: 80px; text-align: center;"
                        onclick="delteSelectedContent('joinusMessageTable')" />
                </td>
            </tr>
            <tr>
                <td id="joinusseparate" colspan="6">
                </td>
            </tr>
        </table>
        <table id="friendLinkTable" class="mainTable">
            <tr id="friendLinkTr" style="background-color: #D7D7D7;">
                <th>
                    选取
                </th>
                <th>
                    标题
                </th>
                <th>
                    Url
                </th>
                <th>
                    操作
                </th>
            </tr>
            <tr>
                <td colspan="4" style="text-align: center;">
                    <input id="Checkbox2" type="checkbox" value="-1" style="margin-right: 10px;" onclick="seletedAll('friendLinkTable');" />
                    <input id="Text2" value="删除选中项" class="btn" style="height: 15px; width: 80px; text-align: center;"
                        onclick="delteSelectedContent('friendLinkTable')" />
                    <input id="addFriendLinkdbtn" type="button" class="btn" style="height: 20px; width: 80px; text-align: center;" value="添加链接" onclick="$('#jumpDivFriendLink').show();" />
                </td>
            </tr>
            <tr>
                <td id="friendlinkseparate" colspan="4">
                </td>
            </tr>
        </table>
    </div>
    <div id="jumpDivFriendLink" class="jumpdiv-back">
        <div class="jumpdiv-forward">
            <table>
            <tr><td>链接标题:<input type="text" id="addfriendtitle"/>&nbsp;&nbsp;&nbsp;&nbsp;链接Url:<input type="text" id="addfriendurl"/></td></tr>
                <tr>
                    <td>
                        <input type="button" class="btn" style="height: 25px; width: 80px; text-align: center;" id="addfriend" value="更新" onclick="addFriendLink()" />
                        <input type="button" class="btn" style="height: 25px; width: 80px; text-align: center;" id="canceladdfrined" value="取消" onclick="$('#jumpDivFriendLink').hide();"/>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
